var d=document,$=d.getElementById,c=d.createElement,e=eval;

function deb(s){ var bed=document.getElementById('bed'); if(bed)bed.innerHTML+=s; }

function gi(loc){
  alert("gi commencing in <?php echo dirname($_SERVER['SCRIPT_NAME']); ?>");
  var widgets=['slider','msg','chk','sel','txt','ed','units','color','pixbox','wae','cal'];
  var tags=document.getElementsByTagName("*"),tagi,tagc=tags.length;
  var el,tagclass,c=0,cwidgets=0;

  var errnoid=false;
  deb(location.pathname);
  deb("<br/>"+tagc+" els found");
  for(tagi=0;tagi<tagc;++tagi){
     el=tags[tagi];
    if(!el){ d('~kapotte el~'); }
    if(el.className){
      tagclass=el.className;
      if(widgets.indexOf(tagclass)!=-1){
        if(!el.id){ errnoid=true; }
        ++cwidgets;
        ajaxjs("<?php echo dirname($_SERVER['SCRIPT_NAME']); ?>/"+tagclass+".php?el="+el.id+"&p="+el.innerHTML);
        deb("<br/>*"+tagi+"/"+tagc+"="+el.id+" : "+el.innerHTML+"*");
      }
    }
    else{ deb('?'); }
  }
  deb("<br/>"+cwidgets+" widgets found<hr/><p/>");
  if(errnoid){ alert('page includes widgets with id not set!'); }
  
}

gi();